﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Twodi.Implemented;
using Twodi.Utility;
using Microsoft.Xna.Framework;
using Twodi.Enums;

namespace Pong.Components
{
    public class Ball : Sprite
    {

        public Vector2 Velocity
        {
            get;
            set;
        }

        public int Radius
        {
            get;
            set;
        }

        public Ball(int radius, Color color, Game game)
            : base(Helper.CreateCircleTexture(game, radius, color, color), game)
        {
            Radius = radius;
            Velocity = new Vector2(2, -2);

            LimitedProperties.TouchLimits += (sender, e) =>
            {
                if (e.Exit == Direction.North ||
                    e.Exit == Direction.South)
                {
                    Velocity = new Vector2(Velocity.X, -Velocity.Y);
                }
            };
        }

        public override void Update(GameTime gameTime)
        {
            Position += Velocity;
            base.Update(gameTime);
        }
    }
}
